<%@ page contentType="text/html; charset=utf-8"%>
<%@ include file="../../../common/include.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
<jsp:include page="../../../common/head.jsp">
	<jsp:param name="_useTab" value="true"/>
	<jsp:param name="_useUpload" value="true"/>
</jsp:include>
<script language="javascript">
	var saveState = false;
	function saveinfo()
	{
		xj.extArrayAllowed = new Array('.xls','.jasper');
		if(saveState==true)
		{
			var objarr = new Array(
				["reportEngine.reportId","报表编号","notEmpty",""],
				["reportEngine.reportId","报表编号","max","String:50"],
				["reportEngine.reportName","报表名称","notEmpty",""],
				["reportEngine.reportName","报表名称","max","String:50"],
				["reportEngine.belongTable","所属模块","notEmpty",""],
				["reportEngine.belongTable","所属模块","max","String:50"],
				["reportEngine.exportServiceName","导出数据源类","max","String:100"],
				["reportEngine.exportFunctionName","导出数据源方法","max","String:100"],
				["reportEngine.importServiceName","导入业务类","max","String:100"],
				["reportEngine.importFunctionName","导入业务方法","max","String:100"],
				["reportEngine.dynamicTitleServiceName","导入业务类","max","String:100"],
				["reportEngine.dynamicTitleFunctionName","导入业务方法","max","String:100"],
				["reportEngine.reportParam","报表参数","max","String:200"],
				["reportEngine.reportFilter","报表过滤条件","max","String:500"],
				["reportEngine.pageBreakColum","分页符所在列","int","4"],
				["reportEngine.columWidthRow","列宽标识数据所在列","int","4"],
				["reportEngine.reportNote","报表说明","max","String:500"]
			);
		
			if(xj.CheckAll(objarr))
			{
				if(confirm("确认保存？"))
				{
					return true;
				}
			}
		}
		return false;
	}
	function checkReportId()
	{
		var tmp = parseInt(Math.random()*10000+1);//设定随机数防止浏览器以相同url重复多次访问不进行请求
		var url = 'checkExistsReportEngine.do?reportId='+$("#reportId").val()+"&tmp="+tmp;
		$.get(url, {},function (data, textStatus){
			if(data=="ok")
			{
				saveState = true;
			}
			else
			{
				xj.showNoticeDiv(document.getElementById("reportId"),"报表编码已存在，请重新设置！",true);
			}
		});
		saveState = false;
	}
	//返回
	function goback()
	{
		window.location.href="listReportEngine.do";
	}
	function setFileState()
	{
		var fileType = $("#reportType").find("option:selected").val();
		if(fileType=="jxl")
			$("#uploadFileTr").css("display","none");
		else
			$("#uploadFileTr").css("display","");
	}
	$(document).ready(function()
	{
		xjTabs.initTab();
	});
</script>

<title>添加报表模板</title>
</head>
<body>
<form action="insReportEngine.do" method="post" name="form1" onsubmit="return saveinfo()" enctype="multipart/form-data">
<div id="body_div">
	<w:ShowTitle name="添加报表模板">
	<w:TitleButton funcName="保存" onClickFunction="" urlImg="${ctx}/images/main/save.png" funcType="submit"/>
	<w:TitleButton funcName="返回" onClickFunction="goback()" urlImg="${ctx}/images/main/back.png"/>
	</w:ShowTitle>
	<div id="body_content">
	<div class="Sliding_tab">
		<ul>
			<li></li><li><span class="tabsLink" id="setTab0" link="#">报表信息</span></li><li></li>
			<li></li><li><span class="tabsLink" id="setTab1" link="#">用户共享</span></li><li></li>
		</ul>
	</div>
  <table width="100%" id="content0" class="tabContent">
    <tr>
	   <td width="120">模板编号</td>
	   <td class="left_align" width="180"><input type="text" name="reportEngine.reportId" id="reportId" onblur="checkReportId()"/></td>
	   <td width="120">模板名称</td>
	   <td class="left_align"><input type="text" name="reportEngine.reportName"/></td>
    </tr>
    <tr>
	   <td>所属模块</td>
	   <td class="left_align"><input type="text" name="reportEngine.belongTable"/></td>
	   <td>报表类型</td>
	   <td class="left_align">
	   		<w:select name="reportEngine.reportType" onchange="setFileState()" styleId="reportType">
	   			<w:option optionLabel="excel报表" optionValue="jxl"></w:option>
	   			<w:option optionLabel="excel模板型报表" optionValue="jxls"></w:option>
	   			<w:option optionLabel="jasperReport报表" optionValue="jasperReport"></w:option>
	   		</w:select>
	   </td>
    </tr>
    <tr>
	   <td>导出数据源类</td>
	   <td class="left_align"><input type="text" name="reportEngine.exportServiceName"/></td>
	   <td>导出数据源方法</td>
	   <td class="left_align"><input type="text" name="reportEngine.exportFunctionName"/></td>
    </tr>
    <tr>
	   <td>导入业务类</td>
	   <td class="left_align"><input type="text" name="reportEngine.importServiceName"/></td>
	   <td>导入业务方法</td>
	   <td class="left_align"><input type="text" name="reportEngine.importFunctionName"/></td>
    </tr>
    <tr>
	   <td>动态表头业务类(jxl)</td>
	   <td class="left_align"><input type="text" name="reportEngine.dynamicTitleServiceName"/></td>
	   <td>动态表头业务方法(jxl)</td>
	   <td class="left_align"><input type="text" name="reportEngine.dynamicTitleFunctionName"/></td>
    </tr>
    <tr>
		<td>报表参数</td>
        <td class="left_align" colspan="3"><input type="text" name="reportEngine.reportParam" style="width:450px;"/></td>
	</tr>
    <tr>
		<td>过滤条件</td>
        <td class="left_align" colspan="3"><input type="text" name="reportEngine.reportFilter" style="width:450px;"/></td>
	</tr>
    <tr>
	   <td>模板是否进行分页(jxls)</td>
	   <td class="left_align">
	   		<input type="radio" name="reportEngine.isPageBreak" value="是" class="radio"/>是
	   		<input type="radio" name="reportEngine.isPageBreak" value="否" checked="checked" class="radio"/>否
	   </td>
	   <td>分页符所在列(jxls)</td>
	   <td class="left_align"><input type="text" name="reportEngine.pageBreakColum"/></td>
    </tr>
    <tr>
	   <td>是否重新设置列宽(jxls)</td>
	   <td class="left_align">
	   		<input type="radio" name="reportEngine.isSetColumWidth" value="是" class="radio"/>是
	   		<input type="radio" name="reportEngine.isSetColumWidth" value="否" checked="checked" class="radio"/>否
	   </td>
	   <td>列宽数据所在行(jxls)</td>
	   <td class="left_align"><input type="text" name="reportEngine.columWidthRow"/></td>
    </tr>
    <tr>
	   <td>报表级别</td>
	   <td class="left_align">
			<input class="radio" type="radio" name="reportEngine.shareType" value="系统" checked="checked"/>系统
			<input class="radio" type="radio" name="reportEngine.shareType" value="用户"/>用户
	   </td>
	   <td></td>
	   <td class="left_align"></td>
    </tr>
	<tr>
		<td>说明</td>
        <td class="left_align" colspan="3"><textarea name="reportEngine.reportNote" rows="5" cols="80"></textarea></td>
	</tr>
	<tr id="uploadFileTr" style="display:none;">
		<td>模板位置</td>
        <td class="left_align">
        	<input type="text" name="templatePath"/>
        </td>
		<td>附件</td>
        <td class="left_align">
        	<w:uploadFile isList="false" isAdd="true" fileCount="1" folder="report"></w:uploadFile>
        </td>
	</tr>
</table>
<table width="100%" id="content1" class="tabContent">
    <tr>
		<td class="td_title" width="40"><span onClick="xjCommon.checkAll('reportOwnerId_u');">全选</span></td>
		<td class="td_title" width="80">允许修改</td>
		<td width="120" class="td_title">用户ID</td>
		<td class="td_title">用户姓名</td>
		<td width="120" class="td_title">分组标识</td>
    </tr>
    <c:forEach items="${userList}" var="obj">
    <tr>
		<td><input type="checkbox" name="reportOwnerId_u" class="checkbox" value="${obj.userId}"/> </td>
		<td>
			<input class="radio" type="radio" name="editAble${obj.userId}" value="${obj.userId}"/>是
			<input class="radio" type="radio" name="editAble${obj.userId}" value="" checked="checked"/>否
		</td>
		<td>${obj.userId}</td>
		<td>${obj.userName}</td>
		<td>${obj.groupSign}</td>
    </tr>
    </c:forEach>
</table>

</div>
</div>
</form>
</body>
</html>
